package com.itzmn.newcode.offer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;

/**
 * @Author: 张梦楠
 * @Date: 2018/11/16 15:28
 * 简书：https://www.jianshu.com/u/d611be10d1a6
 * 码云：https://gitee.com/zhangqiye
 * @Description: 剑指Offer 计算1到n之间的数中一共有多少个1
 *
 *  思路：
 *   1   10   2
 *   11  20   10
 *   21  30   1
 *   31  40   1
 *   91  100  2
 *
 *     16
 */
public class CountNumHasOneNum {


    public static void main(String[] args) {

        new CountNumHasOneNum().NumberOf1Between1AndN_Solution(10000);
    }



    public int NumberOf1Between1AndN_Solution(int n) {

        ArrayList<Integer> integers = new ArrayList<>();
        integers.add(10);
        integers.add(14);
        integers.add(7);
        integers.add(8);
        integers.add(12);
        integers.add(3);


        Collections.sort(integers, new Comparator<Integer>(){
            @Override
            public int compare(Integer str1, Integer str2){

                return str1.compareTo(str2);
            }
        });
        System.out.println(integers);
        return 0;
    }
}
